<cfsilent><!--- attributes.view - defines which display mode to show: day, week, weeklist, month, condensed --->
<cfparam name="attributes.view" type="string" default="list" />
<!--- attributes.rsCategories - a recordset of categories to populate the category select box --->
<cfparam name="attributes.categoriesRS" type="query" />
<!--- attributes.categoryID - defines which category to pull in our recordset --->
<cfparam name="attributes.categoryID" type="numeric" default="0" />
<!--- attributes.linkDate - defines the starting date of our recordset --->
<cfparam name="attributes.linkDate" type="date" default="#now()#" />
<!--- attributes.eventRecords - an array of structs containing the recordset --->
<cfparam name="attributes.eventRecords" type="array" default="0" />
<!--- attributes.ExcludeTimeHeader - boolean to specifiy if the header on the calendar for times is displayed --->
<cfparam name="attributes.ExcludeTimeHeader" type="boolean" default="no" />
<!--- attributes.TooltipSubLength - the length to concatenate the Title string for the tooltips --->
<cfparam name="attributes.TooltipSubLength" type="string" default="35" />
<!--- attributes.maxDescriptionSize - the length to concatenate the Description string for the tooltips --->
<cfparam name="attributes.maxDescriptionSize" type="numeric" default="150" />
<!--- attributes.calendarLinkPage - the page that the user is taken to when they click an event --->
<cfparam name="attributes.calendarLinkPage" type="string" default="" />
<!--- attributes.urlAddString - a URL string to add to the calendarLinkPage attribute --->
<cfparam name="attributes.urlAddString" type="string" default="" />

<cfscript>
	dayOfWeek = dayOfWeek(attributes.linkDate);
	firstDay = createODBCDate(dateAdd('d', dayOfWeek, attributes.linkDate));
	eventRecords = attributes.eventRecords;
</cfscript>
</cfsilent>
<!--- display our top navigation --->
<table class="calendarTable" cellspacing="0">
<tr>
	<td class="calendarNav">
	<cfform method="post" action="#cgi.script_name#" id="daySelector" class="allForms">
	<div><input type="hidden" name="view" value="day" />
	<input type="hidden" name="categoryID" value="<cfoutput>#attributes.categoryID#</cfoutput>" />
	<select name="linkdate" class="calendarSelectBoxes" onchange="changeDay();">
		<cfloop index="loopcount" from="-10" to="10">
		<cfset optionday = dateadd('d', loopcount, firstday)>
		<option<cfif attributes.linkdate eq optionday>  selected="selected"</cfif>><cfoutput>#dateformat(optionday, 'mmmm d, yyyy')#</cfoutput></option></cfloop>
	</select></div></cfform></td>
	<td class="calendarNav" style="text-align: right;">
	<cfform method="post" action="#cgi.script_name#" id="viewchange" class="allForms">
	<div><input type="hidden" name="linkdate" value="<cfoutput>#attributes.linkDate#</cfoutput>" id="linkDate" />
	<input type="hidden" name="categoryID" value="<cfoutput>#attributes.categoryID#</cfoutput>" />
	<select name="view" class="calendarSelectBoxes" onchange="document.getElementById('viewchange').submit();">
		<option value="day" selected="selected">day</option>
		<option value="week">week</option>
		<option value="weeklist">week list</option>
		<option value="month">month</option>
		<option value="list">condensed</option>
	</select></div></cfform>
	</td>
	<cfif day(now()) neq day(attributes.linkDate)>
	<td class="calendarNav" style="text-align: center;">
	<cfform action="#cgi.script_name#" method="post" id="viewweek" class="allForms">
	<div><input type="hidden" name="linkDate" value="<cfoutput>#dateformat(now(), 'mmmm d, yyyy')#</cfoutput>" id="link3date" />
	<input type="hidden" name="categoryID" value="<cfoutput>#attributes.categoryID#</cfoutput>" />
	<input type="hidden" name="view" value="day" />
	<input type="submit" name="submit" value=" today " class="calendarButtons" /></div></cfform></td>
	<cfelse>
	<td class="calendarNav"></td>
	</cfif>
	<td class="calendarNav" style="text-align: right;">
	<cfform method="post" action="#cgi.script_name#" id="categoryChange" class="allForms">
	<div><input type="hidden" name="linkDate" value="<cfoutput>#attributes.linkDate#</cfoutput>" id="linkDate" />
	<input type="hidden" name="view" value="<cfoutput>#attributes.view#</cfoutput>" />
	<select name="categoryID" class="calendarSelectBoxes" onchange="document.getElementById('categoryChange').submit();">
		<cfoutput query="attributes.categoriesRS">
		<option value="#categoryID#"<cfif attributes.categoryID eq categoryID> selected</cfif>>#left(categoryName, 25)#</option>
		</cfoutput>
		<option value="0"<cfif attributes.categoryID eq 0> selected</cfif>>all</option>	
	</select></div></cfform></td>	
</tr>
</table>
<table class="calendarTable" cellspacing="0">
<cfoutput>
<tr>
	<td class="weeklisttimes"></td>
	<td class="weeklistdescription"><cfset isdata = 0 /><cfloop index="i" from="1" to="#ArrayLen(eventRecords)#">
	<cfif NOT Len(Trim(eventRecords[i].StartTime))><cfsilent>
	<cfset isdata = isdata + 1 />
	<cfset variables.tooltipHeader = DateFormat(attributes.LinkDate,  "mmmm, d") />
	<cfif Len(Trim(eventRecords[i].StartTime))>
		<cfset variables.tooltipHeader = variables.tooltipHeader & "&nbsp;&nbsp;&nbsp;" & TimeFormat(eventRecords[i].StartTime, 'h:mm tt') />
	</cfif>
	<cfset variables.tooltipHeader = variables.tooltipHeader & " - " & Left(Trim(eventRecords[i].Title), attributes.TooltipSubLength) />
	<cfif len(eventRecords[i].Teaser)>
		<cfset variables.tooltipBody = Left(eventRecords[i].Teaser, attributes.maxDescriptionSize) />
		<cfif Len(eventRecords[i].Teaser) gt attributes.maxDescriptionSize>
			<cfset variables.tooltipBody = variables.tooltipBody & " ..." />
		</cfif>
	<cfelse>
		<cfset variables.tooltipBody = Left(eventRecords[i].Description, attributes.maxDescriptionSize) />
		<cfif Len(eventRecords[i].Description) gt attributes.maxDescriptionSize>
			<cfset variables.tooltipBody = variables.tooltipBody & " ..." />
		</cfif>
	</cfif>
	</cfsilent><div <cfif len(eventRecords[i].Teaser) OR len(eventRecords[i].Description)>title="header=[#variables.tooltipHeader#] body=[#variables.tooltipBody#] cssbody=[calendarTooltipSub] cssheader=[calendarTooltip]"</cfif> class="weeklisteventdisplay"<cfif application.KConfig.getUseCategoryColors() AND Len(Trim(eventRecords[i].CategoryBGColor))> style="background-color: ###eventRecords[i].CategoryBGColor#;"</cfif>><a href="#attributes.calendarLinkPage#?#eventRecords[i].EventIDLabel#=#eventRecords[i].EventID#&amp;View=#attributes.View#&amp;linkDate=#UrlEncodedFormat(Attributes.linkDate)#<cfif len(attributes.urlAddString)>#attributes.urlAddString#</cfif>" class="weeklistlink"<cfif application.KConfig.getUseCategoryColors() AND Len(Trim(eventRecords[i].CategoryTextColor))> style="color: ###eventRecords[i].CategoryTextColor#;"</cfif>>#Trim(eventRecords[i].Title)#</a></div>
	<div style="display:none;" class="vevent">
	<span class="dtstamp">#DateFormat(Now(), "yyyy-mm-dd")#T#TimeFormat(Now(), "HH:mm:ss")#</span>
	<span class="summary title">#Trim(eventRecords[i].Title)#</span>
	<a href="http://#cgi.server_name#/#attributes.calendarLinkPage#?#eventRecords[i].EventIDLabel#=#eventRecords[i].EventID#&amp;View=#attributes.View#&amp;linkDate=#UrlEncodedFormat(Attributes.linkDate)#<cfif len(attributes.urlAddString)>#attributes.urlAddString#</cfif>" class="url">Event Link</a>
	<div class="description">#eventRecords[i].Description#</div>
	<span class="dtstart" title="#DateFormat(eventRecords[i].StartDate, "yyyy-mm-dd")#<cfif Len(Trim(eventRecords[i].StartTime))>T#TimeFormat(eventRecords[i].StartTime, "HH:mm:ss")#</cfif>">#DateFormat(eventRecords[i].StartDate, "yyyy-mm-dd")#<cfif Len(Trim(eventRecords[i].StartTime))>T#TimeFormat(eventRecords[i].StartTime, "HH:mm:ss")#</cfif></span>
	<cfif eventRecords[i].StartDate neq eventRecords[i].EndDate AND eventRecords[i].StartTime neq eventRecords[i].EndTime><span class="dtend" title="<cfif eventRecords[i].EndDate neq eventRecords[i].StartDate>#DateFormat(eventRecords[i].EndDate, "yyyy-mm-dd")#<cfelse>#DateFormat(eventRecords[i].StartDate, "yyyy-mm-dd")#</cfif><cfif Len(Trim(eventRecords[i].EndTime))>T#TimeFormat(eventRecords[i].EndTime, "HH:mm:ss")#</cfif>"><cfif eventRecords[i].EndDate neq eventRecords[i].StartDate>#DateFormat(eventRecords[i].EndDate, "yyyy-mm-dd")#<cfelse>#DateFormat(eventRecords[i].StartDate, "yyyy-mm-dd")#</cfif><cfif Len(Trim(eventRecords[i].EndTime))>T#TimeFormat(eventRecords[i].EndTime, "HH:mm:ss")#</cfif></span></cfif>
	</div></cfif>
	</cfloop><cfif NOT isdata>&nbsp;</cfif></td>
</tr></cfoutput>
<cfset isdata = 0 />
<cfloop from="0" to="23" index="k">
<cfoutput><tr>
	<td class="weeklisttimes">#TimeFormat(DateAdd("h", k, "12:00 AM"), "h:mm tt")#</td>
	<td class="weeklistdescription"><cfloop index="i" from="1" to="#ArrayLen(eventRecords)#">
	<cfif TimeFormat(eventRecords[i].StartTime) gte DateAdd("h", k, "12:00:00 AM") AND TimeFormat(eventRecords[i].StartTime) lte DateAdd("n", 59, DateAdd("h", k, "12:00:00 AM"))><cfsilent>
	<cfset isdata = isdata + 1 />
	<cfset variables.tooltipHeader = DateFormat(attributes.linkDate,  "mmmm, d") />
	<cfif len(trim(eventRecords[i].StartTime))>
		<cfset variables.tooltipHeader = variables.tooltipHeader & "&nbsp;&nbsp;&nbsp;" & TimeFormat(eventRecords[i].StartTime, 'h:mm tt') />
	</cfif>
	<cfif eventRecords[i].StartDate neq eventRecords[i].EndDate>
		<cfset variables.tooltipHeader = variables.tooltipHeader & "&nbsp;&nbsp;-&nbsp;&nbsp;" & DateFormat(attributes.linkDate,  "mmmm") & " " & DateFormat(eventRecords[i].EndDate, "d") />
	</cfif>
	<cfif len(trim(eventRecords[i].EndTime))>
		<cfset variables.tooltipHeader = variables.tooltipHeader & "&nbsp;&nbsp;&nbsp;" & TimeFormat(eventRecords[i].EndTime, 'h:mm tt') />
	</cfif>
	<cfset variables.tooltipHeader = variables.tooltipHeader & " - " & Left(Trim(eventRecords[i].Title), attributes.TooltipSubLength) />
	<cfif len(eventRecords[i].Teaser)>
		<cfset variables.tooltipBody = Left(eventRecords[i].Teaser, attributes.maxDescriptionSize) />
		<cfif Len(eventRecords[i].Teaser) gt attributes.maxDescriptionSize>
			<cfset variables.tooltipBody = variables.tooltipBody & " ..." />
		</cfif>
	<cfelse>
		<cfset variables.tooltipBody = Left(eventRecords[i].Description, attributes.maxDescriptionSize) />
		<cfif Len(eventRecords[i].Description) gt attributes.maxDescriptionSize>
			<cfset variables.tooltipBody = variables.tooltipBody & " ..." />
		</cfif>
	</cfif>
	</cfsilent><div <cfif len(eventRecords[i].Teaser) OR len(eventRecords[i].Description)>title="header=[#variables.tooltipHeader#] body=[#variables.tooltipBody#] cssbody=[calendarTooltipSub] cssheader=[calendarTooltip]"</cfif> class="weeklisteventdisplay"<cfif application.KConfig.getUseCategoryColors() AND Len(Trim(eventRecords[i].CategoryBGColor))> style="background-color: ###eventRecords[i].CategoryBGColor#;"</cfif>><a href="#attributes.calendarLinkPage#?#eventRecords[i].EventIDLabel#=#eventRecords[i].EventID#&amp;View=#attributes.View#&amp;linkDate=#UrlEncodedFormat(Attributes.linkDate)#<cfif len(attributes.urlAddString)>#attributes.urlAddString#</cfif>" class="weeklistlink"<cfif application.KConfig.getUseCategoryColors() AND Len(Trim(eventRecords[i].CategoryTextColor))> style="color: ###eventRecords[i].CategoryTextColor#;"</cfif>>#Trim(eventRecords[i].Title)#</a></div>
	<div style="display:none;" class="vevent">
	<span class="dtstamp">#DateFormat(Now(), "yyyy-mm-dd")#T#TimeFormat(Now(), "HH:mm:ss")#</span>
	<span class="summary title">#Trim(eventRecords[i].Title)#</span>
	<a href="http://#cgi.server_name#/#attributes.calendarLinkPage#?#eventRecords[i].EventIDLabel#=#eventRecords[i].EventID#&amp;View=#attributes.View#&amp;linkDate=#UrlEncodedFormat(Attributes.linkDate)#<cfif len(attributes.urlAddString)>#attributes.urlAddString#</cfif>" class="url">Event Link</a>
	<div class="description">#eventRecords[i].Description#</div>
	<span class="dtstart" title="#DateFormat(eventRecords[i].StartDate, "yyyy-mm-dd")#<cfif Len(Trim(eventRecords[i].StartTime))>T#TimeFormat(eventRecords[i].StartTime, "HH:mm:ss")#</cfif>">#DateFormat(eventRecords[i].StartDate, "yyyy-mm-dd")#<cfif Len(Trim(eventRecords[i].StartTime))>T#TimeFormat(eventRecords[i].StartTime, "HH:mm:ss")#</cfif></span>
	<cfif eventRecords[i].StartDate neq eventRecords[i].EndDate AND eventRecords[i].StartTime neq eventRecords[i].EndTime><span class="dtend" title="<cfif eventRecords[i].EndDate neq eventRecords[i].StartDate>#DateFormat(eventRecords[i].EndDate, "yyyy-mm-dd")#<cfelse>#DateFormat(eventRecords[i].StartDate, "yyyy-mm-dd")#</cfif><cfif Len(Trim(eventRecords[i].EndTime))>T#TimeFormat(eventRecords[i].EndTime, "HH:mm:ss")#</cfif>"><cfif eventRecords[i].EndDate neq eventRecords[i].StartDate>#DateFormat(eventRecords[i].EndDate, "yyyy-mm-dd")#<cfelse>#DateFormat(eventRecords[i].StartDate, "yyyy-mm-dd")#</cfif><cfif Len(Trim(eventRecords[i].EndTime))>T#TimeFormat(eventRecords[i].EndTime, "HH:mm:ss")#</cfif></span></cfif>
	</div></cfif>
	</cfloop><cfif NOT isdata>&nbsp;</cfif><cfset isdata = 0 /></td>
</tr>
</cfoutput>
</cfloop>				
</table> 